<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@page import="org.ipo.mm.web.util.pager.AbstractPager, org.ipo.mm.web.util.ConstantManager, java.util.Collection, org.ipo.mm.web.util.security.SecurityManager, java.util.Vector" %>
<%@taglib prefix="l" uri="http://struts.apache.org/tags-logic" %>
<%@taglib prefix="b" uri="http://struts.apache.org/tags-bean" %>
<%@taglib prefix="h" uri="http://struts.apache.org/tags-html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<script type="text/javascript">
<!--
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}
// -->
</script>

<h1><b:message key="menu_institutions_mails"/></h1>
<b:message key="institutions_select_envelopes_mail_text"/>
<h:form action="/protected/print_mail_inst">
   <div style="margin: 10px;">
        <h:submit property="operation" styleId="defaultButton"><b:message key="menu_institutions_mails"/></h:submit>
        <input type="button" onclick="SetAllCheckBoxes('InstitutionSelectBean', 'selectedInstitutions', true);" value="<b:message key='gen_select_all'/>">
        <input type="button" onclick="SetAllCheckBoxes('InstitutionSelectBean', 'selectedInstitutions', false);" value="<b:message key='gen_select_none'/>">
    </div>
<div>
    <table id="institutionListTable" class="display">
          <thead>
		  <tr>
			<th><b:message key="repr_select_mail"/></th>
            <th><b:message key="inst_name"/></th>
			<th scope="col"><b:message key="inst_email"/></th>
							<th scope="col"><b:message key="inst_type"/></th>
				<th scope="col"><b:message key="inst_family"/></th>
				<th scope="col"><b:message key="inst_region"/></th>
		</tr>
		  </thead>
		<tbody>
        <l:iterate id="inst" name="allInst" scope="request">
            <tr>
			  <td>
			  <input name="selectedInstitutions" type="checkbox" value="${inst.id}"/>
                    </td>
                 <td><span>${inst.name}</span></td>
				  <td><span>${inst.email}</span></td>
				  	<td><span>${inst.type.name}</span></td>
					<td><span>${inst.family.name}</span></td>
					<td><span>${inst.region.name}</span></td>

        </l:iterate>
			<tbody>
    </table>
</div>
 <div style="margin: 10px;">
        <h:submit property="operation" styleId="defaultButton"><b:message key="repr_print_envelopes_button"/></h:submit>
        <input type="button" onclick="SetAllCheckBoxes('BulkMailBean', 'selectedInstitutions', true);" value="<b:message key='gen_select_all'/>">
        <input type="button" onclick="SetAllCheckBoxes('BulkMailBean', 'selectedInstitutions', false);" value="<b:message key='gen_select_none'/>">

    </div>
</h:form>
